package ai.people.netmon.framework.domain.archives.vo;

import ai.people.netmon.framework.domain.archives.entity.EsResult;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * 网络活动VO
 *
 * @author zhenglin
 * @date 2022/03/31
 * @since 2022/3/31
 */
@Data
@NoArgsConstructor
public class NetworkActivitiesVO {

    /**
     * 头像
     */
    private String portrait;

    /**
     * 帐户名称
     */
    private String accountName;
    /**
     * 帐户id
     */
    private String accountId;
    /**
     * 发言内容
     */
    private String sendMsg;
    /**
     * 发言时间
     */
    private String sendTime;
    /**
     * 社交平台
     */
    private String socialPlatform;
    /**
     * 群组名称
     */
    private String groupName;
    /**
     * 群组账户
     */
    private String groupAccount;
    /**
     * url
     */
    private String url;


    public NetworkActivitiesVO(EsResult.Result esResultInfo) {
        String name = esResultInfo.getAuthor().getName();
        String id = esResultInfo.getAuthor().getId();
        this.accountName = StringUtils.isNotBlank(name) ? name : id;
        this.accountId = id;
        this.sendMsg = esResultInfo.getContent();
        this.sendTime = esResultInfo.getPubtime();
        this.socialPlatform = esResultInfo.getSource();
        String groupName = esResultInfo.getGroup().getName();
        String groupAccount = esResultInfo.getGroup().getId();
        this.groupName = StringUtils.isNotBlank(groupName) ? groupName : groupAccount;
        this.groupAccount = groupAccount;
        this.url = esResultInfo.getUrl();
    }
}
